package com.soft.javase.ch08.test.test3;

import java.util.Arrays;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/4/29
 */
public class StringNumberSort {
    public static void main(String[] args) {
        String str = "9 10 12  6  8 15";

        String[] numberStrings = str.split("\\s+");

        int[] numbers = new int[numberStrings.length];
        for (int i = 0; i < numberStrings.length; i++) {
            numbers[i] = Integer.parseInt(numberStrings[i]);
        }

        Arrays.sort(numbers);

        StringBuilder sortedString = new StringBuilder();
        for (int num : numbers) {
            sortedString.append(num).append(" ");
        }

        System.out.println("原始字符串: " + str);
        System.out.println("排序后字符串: " + sortedString.toString().trim());
    }
}
